package com.muyu.system.controller;


import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.poi.ExcelUtil;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.core.web.page.TableDataInfo;
import com.muyu.common.log.annotation.Log;
import com.muyu.common.log.enums.BusinessType;
import com.muyu.common.security.annotation.RequiresPermissions;
import com.muyu.system.domain.DanmoShoppingDoor;
import com.muyu.system.service.IDanmoShoppingDoorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 商品门头 Controller
 * 
 * @author kunzong
 * @date 2024-12-02
 */
@RestController
@RequestMapping("/DanmoShoppingDoor")
public class DanmoShoppingDoorController extends BaseController
{
    @Autowired
    private IDanmoShoppingDoorService danmoShoppingDoorService;

    /**
     * 查询商品门头 列表
     */
    @RequiresPermissions("system:DanmoShoppingDoor:list")
    @GetMapping("/list")
    public Result list(DanmoShoppingDoor danmoShoppingDoor)
    {
        startPage();
        List<DanmoShoppingDoor> list = danmoShoppingDoorService.selectDanmoShoppingDoorList(danmoShoppingDoor);
        return Result.success(list);
    }

    /**
     * 导出商品门头 列表
     */
    @RequiresPermissions("system:DanmoShoppingDoor:export")
    @Log(title = "商品门头 ", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DanmoShoppingDoor danmoShoppingDoor)
    {
        List<DanmoShoppingDoor> list = danmoShoppingDoorService.selectDanmoShoppingDoorList(danmoShoppingDoor);
        ExcelUtil<DanmoShoppingDoor> util = new ExcelUtil<DanmoShoppingDoor>(DanmoShoppingDoor.class);
        util.exportExcel(response, list, "商品门头 数据");
    }

    /**
     * 获取商品门头 详细信息
     */
    @RequiresPermissions("system:DanmoShoppingDoor:query")
    @GetMapping(value = "/{id}")
    public Result getInfo(@PathVariable("id") Long id)
    {
        return Result.success(danmoShoppingDoorService.selectDanmoShoppingDoorById(id));
    }

    /**
     * 新增商品门头 
     */
    @RequiresPermissions("system:DanmoShoppingDoor:add")
    @Log(title = "商品门头 ", businessType = BusinessType.INSERT)
    @PostMapping
    public Result add(@RequestBody DanmoShoppingDoor danmoShoppingDoor)
    {
        return Result.success(danmoShoppingDoorService.insertDanmoShoppingDoor(danmoShoppingDoor));
    }

    /**
     * 修改商品门头 
     */
    @RequiresPermissions("system:DanmoShoppingDoor:edit")
    @Log(title = "商品门头 ", businessType = BusinessType.UPDATE)
    @PutMapping
    public Result edit(@RequestBody DanmoShoppingDoor danmoShoppingDoor)
    {
        return Result.success(danmoShoppingDoorService.updateDanmoShoppingDoor(danmoShoppingDoor));
    }

    /**
     * 删除商品门头 
     */
    @RequiresPermissions("system:DanmoShoppingDoor:remove")
    @Log(title = "商品门头 ", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public Result remove(@PathVariable Long[] ids)
    {
        return Result.success(danmoShoppingDoorService.deleteDanmoShoppingDoorByIds(ids));
    }
}
